package com.example.wangzh.mytest.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.wangzh.mytest.R;

/**
 * Created by wangzh on 2017/6/4.
 */

public class MyLinearLayout extends LinearLayout {
    TextView txt;

    public MyLinearLayout(Context context) {
        super(context);
        init(context, null);
    }

    public MyLinearLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context, attrs);
    }

    public MyLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context, attrs);
    }

    private void init(Context context, AttributeSet attrs) {
        LayoutInflater.from(context).inflate(R.layout.custom_my_linear_layout, this);
        txt = (TextView) findViewById(R.id.txt);
        txt.setText("测试2");
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        setMeasuredDimension(100, 100);
    }
}
